home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Merciful 5
/
Merciful - Disc 5.iso
/
software
/
d
/
devpac
/
devpacv2.0a.dms
/
devpacv2.0a.adf
/
include
/
misc
/
easystart.i
Wrap
Text File
|
1988-10-06
|
1KB
|
67 lines
* some startup code to make a Workbench execute look like the CLI
* based loosely on RKM Vol 1 page 4-36
* Include this at the front of your program
* after any other includes
* note that this needs exec/exec_lib.i
IFND EXEC_EXEC_I
include "exec/exec.i"
ENDC
IFND LIBRARIES_DOSEXTENS_I
include "libraries/dosextens.i
ENDC
movem.l d0/a0,-(sp) save initial values
clr.l returnMsg
sub.l a1,a1
CALLEXEC FindTask find us
move.l d0,a4
tst.l pr_CLI(a4)
beq.s fromWorkbench
* we were called from the CLI
movem.l (sp)+,d0/a0 restore regs
bra end_startup and run the user prog
* we were called from the Workbench
fromWorkbench
lea pr_MsgPort(a4),a0
CALLEXEC WaitPort wait for a message
lea pr_MsgPort(a4),a0
CALLEXEC GetMsg then get it
move.l d0,returnMsg save it for later reply
* do some other stuff here RSN like the command line etc
nop
movem.l (sp)+,d0/a0 restore
end_startup
bsr.s _main call our program
* returns to here with exit code in d0
move.l d0,-(sp) save it
tst.l returnMsg
beq.s exitToDOS if I was a CLI
CALLEXEC Forbid
move.l returnMsg(pc),a1
CALLEXEC ReplyMsg
exitToDOS
move.l (sp)+,d0 exit code
rts
* startup code variable
returnMsg dc.l 0
* the program starts here
even
_main